package integral

import (
	"context"
	"github.com/zeromicro/go-zero/core/logx"
	"private-domain-overseas-service/admin/business/api/internal/svc"
	"private-domain-overseas-service/tools/ent"
	"private-domain-overseas-service/tools/ent/predicate"
)

type IntegralWalletDao struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewIntegralWalletDao(ctx context.Context, svcCtx *svc.ServiceContext) *IntegralWalletDao {
	return &IntegralWalletDao{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

// GetIntegralWalletOne -根据体条件查询单个积分钱包记录
func (l *IntegralWalletDao) GetIntegralWalletOne(cond []predicate.HzIntegralWallet) (*ent.HzIntegralWallet, error) {
	integralWalletInfo, err := l.svcCtx.Orm.HzIntegralWallet.
		Query().
		Where(cond...).
		First(l.ctx)
	if err != nil {
		return nil, err
	}
	return integralWalletInfo, nil
}
